$(function(){
		$('#beginTime').date();
	});

var rootPath = getRootPath();

$(document).ready(function(){

	   function getQueryString(name) {
		    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		    var r = window.location.search.substr(1).match(reg);
		    if (r != null) return unescape(r[2]); return null;
		    }
	   		var userId = getQueryString("userId");
	   		var carId = getQueryString("carId");
	   		
	   		$("#tmUserId").val(userId);
	   		$("#tmCarId").val(carId);

	$('#modalCancel').click(function(){
				window.location.reload();
			});
	
	$('#modalSure').click(function(){
		/* alert($("#beginTime").html()); */
		 $('#lastMaintainDate').val($("#beginTime").html()); 
		 
		 var data={
				 tmUserId:"",
				 tmCarId:"",
				 lastMaintainDate:"",
				 lastMaintainMileage:"",
			    }; 

		    	data.tmUserId = $.trim($("#tmUserId").val()); 
		    	data.tmCarId = $.trim($("#tmCarId").val()); 
			    data.lastMaintainDate = $.trim($("#lastMaintainDate").val()); 
			    data.lastMaintainMileage = $.trim($("#lastMaintainMileage").val()); 
			    
			    
				$.ajax({
					type : 'POST',
					url : rootPath+'/wechat/api/maintain',
					contentType:"application/json",
					data: JSON.stringify(data),
					error:function(XMLHttpRequest, ajaxOptions, thrownError){
						alert("失败");
					},
					success : function(data){
						alert("成功");
					}
				});
		 
	});
});